package com.zt.weibo.database;

import com.zt.weibo.utils.WeiboCons;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * 通过该类创建所需要的数据库。
 * @author zhaotong
 */
public class WeiboDatabaseOpenHelper extends SQLiteOpenHelper
{
	private static final String DATABASENAME = "WeiboDatabase";
	private static final int VERSION = 1;
	
	/**
	 *创建一个名为“OauthInfo”的表，主键为“_id”是自增长的整数；第二列名为“UserName”，保存用户名；
	 *第三列名为“AccessToken”，保存access_token字符；第四列名为“ExpiresIn”，保存expires_in字符。
	 *第五列名为“InvalidDate”，保存相应access_token的到期时间，单位为秒。
	 */
	private static final String DATABASE_CREATE = 
			"create table OauthInfo(_id integer primary key autoincrement, "+ 
			WeiboCons.DB_USER_NAME + " text not null, " + 
			WeiboCons.DB_ACCESS_TOKEN + " text not null, " + 
			WeiboCons.DB_EXPIRES_IN + " text not null, " + 
			WeiboCons.DB_INVALID_DATE + " integer);"; 

	public WeiboDatabaseOpenHelper(Context context)
	{
		super(context, DATABASENAME, null, VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db)
	{
		db.execSQL(DATABASE_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
	{
		// do nothing now
	}
	
}
